/*
 * Copyright (c) 2018. J4dream Created.
 */

package com.j4dream.property.dao;

import com.j4dream.property.model.PostDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PostDao {
    @Insert({
            "INSERT INTO post (get, owner, title, avatar, cover, status, percent, logo, href, updatedAt, createdAt, subDescription, description, activeUser, newUser, star, _like, message, content) ",
            "VALUES (#{get}, #{owner}, #{title}, #{avatar}, #{cover}, #{status}, #{percent}, #{logo}, #{href}, #{updatedAt}, #{createdAt}, #{subDescription}, #{description}, #{activeUser}, #{newUser}, #{star}, #{like}, #{message}, #{content})"
    })
    void insertPost(PostDto postDto);

    @Select("SELECT * FROM post WHERE get=#{get}")
    PostDto findOneById(@Param("get") String id);

    @Select("SELECT * FROM post")
    List<PostDto> getPostList();
}
